/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bibliotekosis.renderers;

import bibliotekosis.Branch;
import bibliotekosis.Publisher;
import bibliotekosis.User;
import java.awt.Component;
import javax.swing.JList;
import javax.swing.plaf.basic.BasicComboBoxRenderer;

/**
 *
 * @author Vytautas
 */         
public class CustomPublisherRenderer extends BasicComboBoxRenderer
{
    
    @Override
    public Component getListCellRendererComponent(
        JList list, Object value, int index,
        boolean isSelected, boolean cellHasFocus)
    {
        super.getListCellRendererComponent(list, value, index,
            isSelected, cellHasFocus);

        if (value != null)
        {
            Publisher item = (Publisher) value;
            setText(item.get("id") + " " + item.get("name"));
        }

        if (index == -1)
        {
            Publisher item = (Publisher)value;
            setText(item.get("id") + " " + item.get("name"));
        }


        return this;
    }
}
